package hr.ctg.domain.model;

// Generated 2007.05.02 22:50:59 by Hibernate Tools 3.2.0.b9

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Immutable;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * TipAdrese generated by hbm2java
 */
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
@Immutable
@Table(name = "tip_adrese", uniqueConstraints = @UniqueConstraint(columnNames = { "naziv" }))
@NamedQueries( { @NamedQuery(name = "TipAdrese.findAll", query = "select ta from TipAdrese ta") })
public class TipAdrese implements java.io.Serializable {

	/**
	 *
	 */
	private static final long serialVersionUID = 261948107340025875L;
	private int idTipaAdrese;
	private String naziv;
	private Set<Adresa> adresas = new HashSet<Adresa>(0);

	public TipAdrese() {
	}

	public TipAdrese(final int idTipaAdrese, final String naziv) {
		this.idTipaAdrese = idTipaAdrese;
		this.naziv = naziv;
	}

	public TipAdrese(final int idTipaAdrese, final String naziv,
			final Set<Adresa> adresas) {
		this.idTipaAdrese = idTipaAdrese;
		this.naziv = naziv;
		this.adresas = adresas;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id_tipa_adrese", unique = true, nullable = false)
	@NotNull
	public int getIdTipaAdrese() {
		return idTipaAdrese;
	}

	public void setIdTipaAdrese(final int idTipaAdrese) {
		this.idTipaAdrese = idTipaAdrese;
	}

	@Column(name = "naziv", unique = true, nullable = false, length = 50)
	@NotNull
	@Length(max = 50)
	public String getNaziv() {
		return naziv;
	}

	public void setNaziv(final String naziv) {
		this.naziv = naziv;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tipAdrese")
	public Set<Adresa> getAdresas() {
		return adresas;
	}

	public void setAdresas(final Set<Adresa> adresas) {
		this.adresas = adresas;
	}

	@Override
	public boolean equals(final Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof TipAdrese)) {
			return false;
		}
		final TipAdrese other = (TipAdrese) obj;
		if (idTipaAdrese != other.getIdTipaAdrese()) {
			return false;
		}
		return true;
	}

}
